package com.niuwa.p2p.utils;

import java.util.HashMap;
import java.util.Iterator;

import net.sf.json.JSONObject;

public class JsonToHashMap {
	
	public static HashMap<String,Object> toHashMap(Object object)  
	{  
	    HashMap<String, Object> data = new HashMap<String, Object>();  
	    // 将json字符串转换成jsonObject  
	    JSONObject jsonObject = JSONObject.fromObject(object);  
	    Iterator it = jsonObject.keys();  
	    // 遍历jsonObject数据，添加到Map对象  
	    while (it.hasNext())  
	    {  
	        String key = String.valueOf(it.next());  
	        Object   value =  jsonObject.get(key);  
	        data.put(key, value);  
	    }  
	    return data;  
	} 

}
